from typing import List

"""
思路：
如果两个区间重叠了，那就合并成一个，区间是两个区间的重叠部分，
如果没重叠，就将弓箭的数量加1，并下一个。
"""


class Solution:
    def findMinArrowShots(self, points: List[List[int]]) -> int:
        if not points:
            return 0

        points.sort(key=lambda balloon: balloon[1])
        print(points)
        pos = points[0][1]
        ans = 1
        for balloon in points:
            if balloon[0] > pos:
                pos = balloon[1]
                ans += 1

        return ans


if __name__ == "__main__":
    points = [
        [3, 9],
        [7, 12],
        [3, 8],
        [6, 8],
        [9, 10],
        [2, 9],
        [0, 9],
        [3, 9],
        [0, 6],
        [2, 8],
    ]
    res = Solution().findMinArrowShots(points)
    print(res)

